package com.songlanyun.modules.freebag.entity;


import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.songlanyun.common.drive.RootEntity;
import com.songlanyun.modules.notifytemp.entity.NotifyTempEntity;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Data
@TableName("yxt_free_bag")
public class FreeBag extends RootEntity<Integer, FreeBag> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId
    private Integer id;
    /**
     * 福利包名称
     */
    @NotBlank(message = "名称不能为空")
    @Length(min = 1, max = 50, message = "名称的长度不能超过50个字")
    private String freeName;
    /**
     * 免费领规则(1每月2一次性)
     */
    @NotNull(message = "领取规则不能为空")
    private Integer freeType;
    /**
     * 免费领取次数
     */
    @NotNull(message = "领取次数不能为空")
    private Integer freeNum;
    /**
     * 积分发放规则(1每月2一次性)
     */
    @NotNull(message = "积分规则不能为空")
    private Integer integralType;
    /**
     * 积分点数
     */
    @NotNull(message = "积分点数不能为空")
    private BigDecimal integralNum;
    /**
     * 状态(0停用1启用)
     */
    private Boolean hasEffect;
    /**
     *
     */
    private Long createBy;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    /**
     *
     */
    private Long updateBy;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;


    public  Boolean isOneFree()
    {
        return this.getFreeType().equals(2);
    }

    /**
     * 是否是一次性发放积分
     * @return
     */
    public  Boolean isOneIntegralType()
    {
        return this.getIntegralType().equals(2);
    }


    @Override
    public Integer getIdentity() {
        return getId();
    }
}
